<?php
/**
 * Created by PhpStorm.
 * User: divya
 * Date: 2018/6/29
 * Time: 下午3:34
 */
$conn = mysqli_connect('localhost',"root","root") or die('connect faild'.mysqli_error());

// 防止中文乱码
//mysqli_query($conn,'SEL NAMES UTF8');
// 选择数据库
mysqli_select_db($conn,"ShowDB")or die('select faild'.mysqli_error());

$tel = $_POST['tel'];
$pas = $_POST['pas'];

// 判断手机号是否重复
$sql = "select *from t_user where user_phone = $tel";
// 执行sql语句
$sql = "insert into t_user (user_phone, user_password) values ( '$tel', '$pas')";
$result = mysqli_query($conn,$sql);
$count = mysqli_affected_rows($conn);
if ($count == 1){
    // 注册成功
    $json = json_encode(array(
        'resultCode'=>200,
        "message"=>'success!',

    ),JSON_UNESCAPED_UNICODE);
    echo ($json);
}else{
    // 注册失败
    $json = json_encode(array(
        'resultCode'=>500,
        "message"=>'failed!',

    ),JSON_UNESCAPED_UNICODE);
    echo ($json);
}
//var_dump($array);
// 关闭数据库
mysqli_close($conn);